package com.Dec_Seventeen;

import java.util.Arrays;

public class Solution792 {


    public int sumSubseqWidths(int[] nums) {
        Arrays.sort(nums);
        double ans=0,k=1,mod=1e9+7;
        //double mod=1e9+7;
        for (int i = 0; i < nums.length; i++) {
            ans=  ((ans+nums[nums.length-i-1]*k-nums[i]*k)%mod);
            k=  ((k*2)%mod);
        }
        return (int)ans;
    }

    public static void main(String[] args) {
        Solution792 solution792=new Solution792();
        System.out.println(solution792.sumSubseqWidths(new int[]{2,1,3}));
    }

}
